﻿/// <reference path="_namespace.js" />
/// <reference path="../components/Component.js" />

/*****************************************************************************
MS Ajax library class definition. Inheriting from ajax.BaseObject.
Author: krobinson 10/8/2008 2:33:03 PM.
Class:  ajax.xna.DomSprite
*****************************************************************************/

$addNamespace("ajax.xna");
//-----------------------------------------------------------------------------

ajax.xna.DomSprite = function(doc, texture, width, height)
{
    ajax.xna.DomSprite.superConstructor.apply(this, arguments);
    this.preInitialize(doc, texture, width, height);
}
$extend("ajax.xna.DomSprite", "ajax.components.Component");

if ($getDesignMode())
    ajax.xna.DomSprite.prototype = ajax.components.Component.prototype;
//-----------------------------------------------------------------------------

// Private members
ajax.xna.DomSprite.prototype._element = null;
ajax.xna.DomSprite.prototype._texture = null;
ajax.xna.DomSprite.prototype._width = 0;
ajax.xna.DomSprite.prototype._height = 0;


// Public members
//-----------------------------------------------------------------------------

// Public Methods
//-----------------------------------------------------------------------------
ajax.xna.DomSprite.prototype.get_texture = function() 
{///<returns type="domElement"/>
    return this._texture;
}
ajax.xna.DomSprite.prototype.set_texture = function(value) { this._texture = value; }
ajax.xna.DomSprite.prototype.get_width = function() { return this._width; }
ajax.xna.DomSprite.prototype.set_width = function(value) { this._width = value; }
ajax.xna.DomSprite.prototype.get_height = function() { return this._height; }
ajax.xna.DomSprite.prototype.set_height = function(value) { this._height = value; }

if ($getDesignMode())
    ajax.xna.DomSprite.prototype._element = domElement.prototype;
ajax.xna.DomSprite.prototype.get_element = function()
{///<returns type="domElement">Returns the underlying Dom (div) element</returns>
    return this._element;
}

ajax.xna.DomSprite.prototype.layerStyle = 
{
    position: "relative",
    top: 0,
    left: 100
};

ajax.xna.DomSprite.prototype.preInitialize = function(doc, texture, width, height)
{            
    this._texture = texture;
    this._width = width;
    this._height = height;
    this._element = this.getDocument().createElement("div");
    this.copyProperties(this._element.style, this.layerStyle, true);       
    this._element.style.backgroundImage = String.toFormat("url('{0}')", texture.src);
}

// Statics
//-----------------------------------------------------------------------------
ajax.xna.DomSprite.cast = function(obj)
{///<returns type="ajax.xna.DomSprite"/>
    return obj;
}